package com.yuezhu.global;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.yuezhu.com_volley.OkRequestQueue;
import com.yuezhu.com_volley.OkVolley;

import org.greenrobot.eventbus.EventBus;


/**
 * Activity基类
 * @创建人：zhaoshuzhen
 * @创建时间：2015/12/8 16:13
 */
public abstract class BaseActivity extends Activity implements View.OnClickListener{
    private Context context;
    protected OkRequestQueue queue ;//网络访问类

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        //将Acitivity中的Window的背景图设置为空
        this.getWindow().setBackgroundDrawable(null);
        queue = OkVolley.newOkRequestQueue(this);
        context = this;
//        EventBus.getDefault().register(this);
        // 加入activity列表
    }


    @Override
    public void onClick(View view) {
    	/*if(DateUtil.isFastClick()){
    		return;
    	}*/
    }

//    /**
//     * actionbar menu文字和图片显示
//     * @param menu
//     * @return
//     */
//    @Override
//    public boolean onCreateOptionsMenu(Menu menu) {
//        getMenuInflater().inflate(R.menu.main_menu, menu);
//        MenuItem menuItem = menu.findItem(R.id.menu_version);
//        initMenuItem(menuItem);
//        MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS );
//        return true;
//    }

//    /**
//     * 初始化菜单
//     * @param menuItem
//     */
//    protected abstract void initMenuItem(MenuItem menuItem);
//
//    /**
//     * 菜单键点击的事件处理
//     */
//    @Override
//    public boolean onOptionsItemSelected(MenuItem item) {
//            onMenuItemSelected(item);
//        return  super.onOptionsItemSelected(item);
//    }

//    protected void onMenuItemSelected(MenuItem item){};
    /**
     * 初始化view
     */
    protected void initView(){};
    /**
     * 设置监听
     */
    protected void setListeners(){};
    //友盟统计相关
    public void onResume() {
        super.onResume();
//        MobclickAgent.onResume(this);
//        BusProvider.getInstance().register(this);
//        StatService.onResume(this) ;
    }
    public void onPause() {
        super.onPause();
       /* MobclickAgent.onPause(this);
        StatService.onPause(this);*/
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
//        BusProvider.getInstance().unregister(this);
//        EventBus.getDefault().unregister(this);
    }
    /**.
     * 启动视觉差返回Activity
     *
     * @param activity
     * @param intent
     */
    public void startParallaxSwipeBackActivty(Activity activity, Intent intent) {
        startParallaxSwipeBackActivty(activity, intent, false);
    }

    /**
     * startParallaxSwipeBackActivty
     *
     * @param activity
     * @param intent
     * @param isFullScreen
     */
    public void startParallaxSwipeBackActivty(Activity activity, Intent intent, boolean isFullScreen) {
        startActivity(intent);
    }
    public void startForResultParallaxSwipeBackActivty(Activity activity, Intent intent) {
    	startForResultParallaxSwipeBackActivty(activity, intent, false);
    }
    private final int REQUESTCODE = 1 ;
    public void startForResultParallaxSwipeBackActivty(Activity activity, Intent intent, boolean isFullScreen) {

        startActivityForResult(intent, REQUESTCODE);
    }
}
